/*
 *  triangle.h
 *  Ray Tracer
 *
 *  Created by Chirantan Ekbote on 10/24/10.
 *  Copyright 2010 Ohio State University. All rights reserved.
 *
 */

#ifndef _TRIANGLE_H_
#define _TRIANGLE_H_

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
	
#include <math.h>
#include "param.h"
#include "vec3.h"
#include "rgb.h"
#include "ray.h"
#include "light.h"
	
struct object;
	
typedef struct triangle {
	vec3 p0;
	vec3 p1;
	vec3 p2;
	rgb ambientColor;
	rgb diffuseColor;
	float shininess;
	float transparency;
} triangle;
	
static inline triangle makeTriangle(const vec3 p0, const vec3 p1, const vec3 p2, 
									const rgb ambient, const rgb diffuse, const float shininess, 
									const float transparency) {
	triangle temp = {p0, p1, p2, ambient, diffuse, shininess, transparency};
	return temp;
}
	
int triangleHit(const triangle* t, const ray* r, double* time);

rgb triangleOnHit(const triangle* t, const ray* r, const vec3 hitPos, 
				  const struct object* shapes, const light* lights, int depth,
				  const param* p);

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _TRIANGLE_H_